package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Skin;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.SkinService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 邵康
 * @date 2021/12/06 11:46
 */
@Api(tags = "个人中心皮肤(背景)相关")
@CrossOrigin
@RestController
@RequestMapping("/skin")
public class SkinController {

    @Autowired
    private SkinService skinService;

    @ApiOperation("添加背景 除了 id都需要")
    @PostMapping("/add")
    public R<Void> add(Skin skin) {
        return skinService.add(skin);
    }

    @ApiOperation("delete")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return skinService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(Skin skin) {
        return skinService.update(skin);
    }

    @ApiOperation("根据当前用户等级获取所有可用背景")
    @GetMapping("/getAll")
    public R<List<Skin>> getAll(){
        return skinService.getAll();
    }

    @ApiOperation("page")
    @GetMapping("/page")
    public R<IPage<Skin>> page(@RequestParam(defaultValue = "1") Integer page,
                               @RequestParam(defaultValue = "10") Integer size) {
        return skinService.page(page, size);
    }

}
